from typing import Optional
from sqlmodel import Field
from models.Base import Base
from enum import Enum
# type 枚举
class ConfigTypeEnum(str, Enum):
    group = 'group'
    string = 'string'
    text = 'text'
    int = 'int'
    radio = 'radio'
    select = 'select'
    select_mult = 'select_mult'
    bool = 'bool'
    array = 'array'
    datetime = 'datetime'
    date = 'date'
    file = 'file'
    files = 'files'

class editBathListConfig(Base):
    value: Optional[str] = Field(max_length=512, default=None, description='配置内容')

class editConfig(Base):
    type: Optional[ConfigTypeEnum] = Field(max_length=60, default=ConfigTypeEnum.group, description='类型')
    title: Optional[str] = Field(max_length=60, default='', description='配置名称')
    value: Optional[str] = Field(max_length=512, default=None, description='配置内容')
    options: Optional[str] = Field(max_length=512, default=None, description='选项配置')
    description: Optional[str] = Field(max_length=255, default=None, description='描述')
    weigh: Optional[int] = Field(default=50, description='权重')

# 基于上面的sql语句，我们可以定义一个对应的模型类
class Config(editConfig, table=True):
    __tablename__ = "sys_config"
    store_range: Optional[str] = Field(max_length=512, default=None, description='配置选项')
    rule: Optional[str] = Field(max_length=60, default=None, description='验证规则')
    code: str = Field(max_length=100, description='配置标识', unique=True)
    parent_code: Optional[str] = Field(max_length=60, default=None, description='上级标识', index=True)
  
